//
//  MainController.m
//  OCWeiBo
//
//  Created by 江潘 on 15/6/25.
//  Copyright © 2015年 江潘. All rights reserved.
//

#import "MainController.h"
#import "HomeController.h"
#import "DiscoverController.h"
#import "MessageController.h"
#import "ProfileController.h"
#import "CustomTabBar.h"

@interface MainController ()

@end

@implementation MainController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addChildviewcontrollers];
    
    [self setValue:[[CustomTabBar alloc] init] forKey:@"tabBar"];
    
}

- (void)addChildviewcontrollers {

    [self addChildviewcontrollerWith:@"首页" andVc:[[HomeController alloc] init] andBarImgName:@"tabbar_home"];
    [self addChildviewcontrollerWith:@"消息" andVc:[[MessageController alloc] init] andBarImgName:@"tabbar_message_center"];
    [self addChildviewcontrollerWith:@"发现" andVc:[[DiscoverController alloc] init] andBarImgName:@"tabbar_discover"];
    [self addChildviewcontrollerWith:@"我" andVc:[[ProfileController alloc] init] andBarImgName:@"tabbar_profile"];
  
}

- (void)addChildviewcontrollerWith:(NSString *)barName andVc:(UIViewController *)vc andBarImgName:(NSString *)img {

    vc.title = barName;
    
    vc.tabBarItem.image = [UIImage imageNamed:img];
    
    vc.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",img]];
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    
    [self addChildViewController:nav];
}


@end
